package com.qys.livesMall.app.user.controller.sys;

import com.qys.livesMall.app.user.model.dto.sys.UserRewardConfigDTO;
import com.qys.livesMall.app.user.model.dto.sys.UserRewardConfigListDTO;
import com.qys.livesMall.app.user.model.entity.UserRewardConfig;
import com.qys.livesMall.app.user.model.vo.sys.UserRewardConfigListVO;
import com.qys.livesMall.app.user.service.UserRewardConfigService;
import com.qys.livesMall.common.result.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 主播奖励配置 前端控制器
 * </p>
 *
 * @author 
 * @since 2023-10-31
 */
@RestController
@Tag(name = "sys-用户用户权限配置")
@RequestMapping("/sys/userRewardConfig")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class SysUserRewardConfigController {

    private final UserRewardConfigService userRewardConfigService;

    @GetMapping("/selectAll")
    @Operation(summary = "查询用户配置权限")
    public R<UserRewardConfigListVO> selectAll(){
        return R.ok(userRewardConfigService.selectAll());
    }

    @PostMapping("/addAll")
    @Operation(summary = "新增用户配置权限")
    public R<Boolean> addAll(@RequestBody UserRewardConfigListDTO dto){
        return R.ok(userRewardConfigService.addAll(dto));
    }

    @PostMapping("/edit")
    @Operation(summary = "编辑单条用户配置权限")
    public R<Boolean> add(@RequestBody UserRewardConfig dto){
        return R.ok(userRewardConfigService.add(dto));
    }

    @PostMapping("/updateType")
    @Operation(summary = "单字段用户配置权限修改")
    public R<Boolean> addAll(@RequestBody UserRewardConfigDTO dto){
        return R.ok(userRewardConfigService.updateType(dto));
    }

    @DeleteMapping("/delete/{id}")
    @Operation(summary = "根据id删除用户配置")
    public R<Void> removeById(@PathVariable String id) {
        userRewardConfigService.removeById(id);
        return R.ok();
    }
}
